home *** CD-ROM | disk | FTP | other *** search
- import sys
- sys.path.insert(0, '..')
- import gl, GL, DEVICE
- import img
- import imgformat
- import imgconvert
-
- imgconvert.settrace(1)
-
- def view(title, fullname):
- print 'Reading from',fullname,'...'
- reader = img.reader(imgformat.rgb, fullname)
- data = reader.read()
- width = reader.width
- height = reader.height
- x1 = 10
- x2 = x1 + width - 1
- y2 = 1000
- y1 = y2 - height + 1
- gl.foreground()
- gl.prefposition(x1, x2, y1, y2)
- win = gl.winopen(title)
- gl.RGBmode()
- gl.gconfig()
- gl.pixmode(GL.PM_TTOB, 1)
-
- gl.lrectwrite(0, 0, width-1, height-1, data)
- gl.qdevice(DEVICE.REDRAW)
- gl.qdevice(DEVICE.ESCKEY)
- gl.qdevice(DEVICE.WINQUIT)
- gl.qdevice(DEVICE.WINSHUT)
- gl.qdevice(DEVICE.QKEY)
- gl.qdevice(DEVICE.WKEY)
- while 1:
- dev, val = gl.qread()
- if dev in (DEVICE.ESCKEY, DEVICE.QKEY, DEVICE.WKEY) and \
- val == 0:
- break
- if dev in (DEVICE.WINSHUT, DEVICE.WINQUIT):
- break
- if dev == DEVICE.REDRAW:
- gl.lrectwrite(0, 0, width-1, height-1, data)
- gl.winclose(win)
- if dev == DEVICE.WKEY:
- import os
- head, tail = os.path.split(fullname)
- if not head:
- head = '.'
- newname = head + '/@copy-'+tail
- print 'Writing to', newname,'...'
- wrr = img.writer(imgformat.rgb, newname)
- wrr.width, wrr.height = width, height
- wrr.write(data)
-
- args = sys.argv[1:]
- if not args:
- print 'Usage:',sys.argv[0],'file ...'
- for a in args:
- view(a, a)
-
-